﻿<Helpers:LayoutAwarePage
    xmlns:Helpers="using:JumpstartApp.Helpers"
    xmlns:Controls="using:JumpstartApp.Controls" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:JumpstartApp"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:ViewModels="using:JumpstartApp.ViewModels"
    x:Class="JumpstartApp.Views.AppHub"
    mc:Ignorable="d">

    <Page.DataContext>
        <ViewModels:AppHubViewModel/>
    </Page.DataContext>

    <Page.Resources>
        <CollectionViewSource x:Name="CVS4Landscape" Source="{Binding Groups4Landscape}" IsSourceGrouped="True" ItemsPath="Children"
            d:Source="{Binding Groups4Landscape, Source={d:DesignInstance IsDesignTimeCreatable=True, Type=ViewModels:AppHubViewModel}}"/>
        <CollectionViewSource x:Name="CVS4Portrait" Source="{Binding Groups4Portrait}" IsSourceGrouped="True" ItemsPath="Children"
            d:Source="{Binding Groups4Portrait, Source={d:DesignInstance IsDesignTimeCreatable=True, Type=ViewModels:AppHubViewModel}}"/>
        <CollectionViewSource x:Name="CVS4Snapview" Source="{Binding Groups4Snapview}" IsSourceGrouped="True" ItemsPath="Children"
            d:Source="{Binding Groups4Snapview, Source={d:DesignInstance IsDesignTimeCreatable=True, Type=ViewModels:AppHubViewModel}}"/>
    </Page.Resources>
    <Helpers:LayoutAwarePage.BottomAppBar>
        <AppBar x:Name="MyBottomAppBar">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition/>
                    <ColumnDefinition/>
                </Grid.ColumnDefinitions>
                <StackPanel Orientation="Horizontal"/>
                <StackPanel Grid.Column="1" HorizontalAlignment="Right" Orientation="Horizontal">
                    <Button HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Style="{StaticResource ShopAppBarButtonStyle}" Command="{Binding UpgradeCommand, Mode=OneWay}"/>
                </StackPanel>
            </Grid>
        </AppBar>
    </Helpers:LayoutAwarePage.BottomAppBar>

    <Grid>

        <Grid x:Name="FillView" Visibility="Visible">
            <Controls:Silhouette x:Uid="AppHubSilhouette" Title="(dev) Windows 8 Development" SubTitle="(dev) C# &amp; XAML" x:Name="MySilhouette" />
            <SemanticZoom>
                <SemanticZoom.ZoomedInView>

                    <Controls:GridView Padding="115,0,80,80" Margin="0,125,0,0" IsSynchronizedWithCurrentItem="False"
                                   ItemsSource="{Binding Source={StaticResource CVS4Landscape}}" 
                                   SelectedItem="{Binding Selected, Mode=TwoWay}">
                        <GridView.ItemTemplateSelector>
                            <Controls:TemplateSelector NormalTemplate="{StaticResource ChildTemplate}" AdTemplate="{StaticResource AdTemplate}" />
                        </GridView.ItemTemplateSelector>
                        <GridView.ItemsPanel>
                            <ItemsPanelTemplate>
                                <StackPanel Orientation="Horizontal" />
                            </ItemsPanelTemplate>
                        </GridView.ItemsPanel>
                        <GridView.GroupStyle>
                            <GroupStyle HeaderTemplate="{StaticResource GroupStyleHeaderTemplate}" Panel="{StaticResource GroupStylePanelTemplate}" />
                        </GridView.GroupStyle>
                    </Controls:GridView>

                </SemanticZoom.ZoomedInView>
                <SemanticZoom.ZoomedOutView>

                    <GridView x:Name="ZoomedOutGridView"
                              Padding="115,0,80,80" Margin="0,125,0,0" 
                              ItemTemplate="{StaticResource ParentTemplate}"
                              HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                        <GridView.ItemsPanel>
                            <ItemsPanelTemplate>
                                <StackPanel Orientation="Horizontal" VerticalAlignment="Center" />
                            </ItemsPanelTemplate>
                        </GridView.ItemsPanel>
                    </GridView>

                </SemanticZoom.ZoomedOutView>
            </SemanticZoom>
            <Controls:Badge HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,50,40,0"/>
        </Grid>
        <Grid x:Name="PortraitView" Background="Gray" HorizontalAlignment="Stretch" Visibility="Collapsed">
            <Controls:Silhouette Title=" " SubTitle=" " />

            <Controls:GridView Padding="115,0,80,80" Margin="0,125,0,0" IsSynchronizedWithCurrentItem="False"
                                   ItemsSource="{Binding Source={StaticResource CVS4Portrait}}" 
                                   SelectedItem="{Binding Selected, Mode=TwoWay}">
                <GridView.ItemTemplateSelector>
                    <Controls:TemplateSelector NormalTemplate="{StaticResource ChildTemplate}" AdTemplate="{StaticResource AdTemplate}" />
                </GridView.ItemTemplateSelector>
                <GridView.ItemsPanel>
                    <ItemsPanelTemplate>
                        <StackPanel Orientation="Horizontal" />
                    </ItemsPanelTemplate>
                </GridView.ItemsPanel>
                <GridView.GroupStyle>
                    <GroupStyle HeaderTemplate="{StaticResource GroupStyleHeaderTemplate}" Panel="{StaticResource GroupStylePanelTemplate}" />
                </GridView.GroupStyle>
            </Controls:GridView>

        </Grid>
        <Grid x:Name="SnapView" Background="Gainsboro" Visibility="Collapsed">
            <Controls:Silhouette Title=" " SubTitle=" " />
            <ListView Padding="40,0,0,80" IsSynchronizedWithCurrentItem="False"
                                   ItemsSource="{Binding Source={StaticResource CVS4Snapview}}"
                                   SelectedItem="{Binding Selected, Mode=TwoWay}">
                <ListView.ItemTemplateSelector>
                    <Controls:TemplateSelector NormalTemplate="{StaticResource ChildTemplate}" AdTemplate="{StaticResource AdTemplate}" />
                </ListView.ItemTemplateSelector>
                <ListView.Header>
                    <TextBlock Margin="0,0,0,40" Padding="0,80,0,0" Style="{StaticResource PageHeaderTextStyle}" TextTrimming="None">Windows 8</TextBlock>
                </ListView.Header>
                <ItemsControl.ItemsPanel>
                    <ItemsPanelTemplate>
                        <StackPanel Orientation="Vertical" />
                    </ItemsPanelTemplate>
                </ItemsControl.ItemsPanel>
                <ItemsControl.GroupStyle>
                    <GroupStyle HeaderTemplate="{StaticResource GroupStyleHeaderTemplate}">
                        <GroupStyle.Panel>
                            <ItemsPanelTemplate>
                                <VariableSizedWrapGrid ItemHeight="144" ItemWidth="256" Orientation="Vertical" />
                            </ItemsPanelTemplate>
                        </GroupStyle.Panel>
                    </GroupStyle>
                </ItemsControl.GroupStyle>
            </ListView>
        </Grid>

        <VisualStateManager.VisualStateGroups>
            <VisualStateGroup x:Name="ApplicationViewStates">
                <VisualState x:Name="FullScreenLandscape">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="FillView" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="SnapView" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PortraitView" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
                <VisualState x:Name="Filled">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="FillView" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="SnapView" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PortraitView" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
                <VisualState x:Name="FullScreenPortrait">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="FillView" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="SnapView" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PortraitView" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
                <VisualState x:Name="Snapped">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="FillView" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="SnapView" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PortraitView" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>
    </Grid>
</Helpers:LayoutAwarePage>
